<?php
namespace cms\modules\frontend\controllers;

use Yii;
use yii\helpers\Html;
use yii\db\Expression;
use cms\controllers\BasicController;
use app\models\GlobalVariable;
use common\component\tool\Tool;
use common\component\exception\ErrMap;


class GlobalparmsController extends BasicController
{

    /*获取单个参数值*/
    public function actionGetParm()
    {
        $parm = isset($this->get['parm'])?$this->get['parm']:'';
        $app_id = $this->app_id;
        if($parm){
            $globalVariable = GlobalVariable::find()
                        ->select(['variable_name', 'explain', 'variable_val'])
                        ->where('app_id = :app_id and variable_name = :parm', [':app_id' => $app_id, ':parm' => $parm])
                        ->asArray()->one();
            // P($globalVariable);
            if(!is_null($globalVariable)){
                return Tool::showRes([0, '获取成功'], $globalVariable);
            }else{
                return Tool::showRes(ErrMap::getError(20002));
            }
        };
        return Tool::showRes(ErrMap::getError(10005));
    }


}
